home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Component;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.MediaTracker;
-
- public class TrackedImageLoad extends Applet implements Runnable {
- MediaTracker tracker;
- int tracked;
- Thread motor;
- boolean loaded;
- Image art;
-
- public void init() {
- this.tracker = new MediaTracker(this);
- this.art = ((Applet)this).getImage(((Applet)this).getDocumentBase(), ((Applet)this).getParameter("img"));
- this.tracker.addImage(this.art, this.tracked++);
- }
-
- public void paint(Graphics var1) {
- if (this.imagesLoaded()) {
- var1.drawImage(this.art, 0, 0, this);
- this.loaded = true;
- }
-
- }
-
- public boolean imagesLoaded() {
- boolean var1 = false;
-
- for(int var2 = 0; var2 < this.tracked; ++var2) {
- var1 &= this.tracker.checkID(var2, true);
- System.out.println(var2 + " : " + (this.loaded ? "done" : "loading"));
- }
-
- return var1;
- }
-
- public void start() {
- this.motor = new Thread(this);
- this.motor.start();
- }
-
- public void stop() {
- this.motor.stop();
- }
-
- public void run() {
- this.motor.setPriority(1);
-
- while(!this.loaded) {
- ((Component)this).repaint();
-
- try {
- Thread.sleep(200L);
- } catch (InterruptedException var1) {
- }
- }
-
- }
- }
-